package io.gitee.zicai.bus.bus;

import io.gitee.zicai.bus.publish.IBusPublisher;
import io.gitee.zicai.bus.support.GuavaEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.stereotype.Component;

/**
 * Bus
 *
 * @author zicai
 * @since 2021-01-20
 */
@Slf4j
@Component
public class Bus {

    @Autowired(required = false)
    private IBusPublisher<ApplicationEvent> cmdBusEventPublisher;
    @Autowired(required = false)
    private IBusPublisher<GuavaEvent> cmdBusGuavaPublisher;

    public <B extends ApplicationEvent> void publish(B bus) {
        cmdBusEventPublisher.publish(bus);
    }

    public <B extends GuavaEvent> void publish(B bus) {
        cmdBusGuavaPublisher.publish(bus);
    }

}
